package com.mjduan.project.goodExample;

/**
 * Hans 2017-09-16 20:22
 */
public class RedTrafficLightState extends State {
    private TrafficLight trafficLight;

    public RedTrafficLightState(TrafficLight trafficLight) {
        this.trafficLight = trafficLight;
    }

    @Override
    public void handleRequest() {
        System.out.println(this.getClass().getName() + ":Turning traffic red-light to green");
        trafficLight.setState(trafficLight.getGreenState());
    }

    @Override
    public String toString() {
        return "Traffic light is red";
    }
}
